<?php defined('IN_NWIDC') or exit('Access Invalid!'); ?>

<div class="tabmenu">
    <?php include template('layout/submenu'); ?>
</div>

<?php
if ($_GET['state_type'] == 'imported_order' && ($output["store_info"]['useIETAPI'] == 1 || $_GET['bin'] == 1)) {
    ?>
    <script src="/packages/excel_import_export/cmay.js"></script>
    <script>
        var mdata = {
            success: [],
            failed: []
        }
    </script>

    <div c-tpl="mdata" class="layertips" style="display: none;">
        <h2>
            成功导入,数量{success.length}
        </h2>
        {each item in success}
        <p>
            {item}
        </p>
        {end}
        <hr>
        <h2>
            导入失败,数量{failed.length}
        </h2>
        {each item in $data.failed}
        <p>
            {item[0]} : {item[1]}
        </p>
        {end}
    </div>
    <script>
        var impcallback = function (data) {
            if (data.errcode != 0) return layer.msg("导入失败");
            mdata.success = data.errmsg.success;
            mdata.failed = data.errmsg.failed;
            $('.layertips').show();
            if (data.errmsg.file) {
                $('.downlink').show();
                $('.downlink a').attr("href", data.errmsg.file).click();
            }
        };
    </script>
    <style>
        .useimportapi div {
            padding-top: 10px;
            padding-bottom: 10px;
        }

        .useimportapi input {
            margin-right: 15px;
        }

        .useimportapi input[type=submit] {
            display: inline-block;
            background: #007eff;
        }
    </style>
    <div class="useimportapi" colspan="100" style="padding-top: 20px;">
        <p style="color:red">
            请在导入前确保excel中所有单元格都设置成了“文本”格式
            <br>
            文件名中请不要出现中文！！
            <br>
            请使用xlsx格式而不是xls格式！
        </p>
        <div>
            <form action="/shop/?sin=SinSexcel&p=memberImport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">

                <input type="submit" value="导入会员(选择xlsx)">
            </form>
        </div>


        <div>
            <form action="/shop/?sin=SinSexcel&p=goodsImport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导入商品(选择zip)">
            </form>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=goodsImport2&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导入商品">
            </form>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=goodsExport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="submit" value="导出商品">
                <!--              <a href="/data/resource/examples/order_examples_20190524.xlsx" target="_blank"><b>下载模板</b></a>-->
            </form>
            <p class="downlink" style="display: none;">
                <a href="" target="_blank">如果下载没有自动开始，请点我下载</a>
            </p>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=orderImport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导入订单(选择xlsx)">
                <label>
                    <input type=checkbox name='use_source' value='1'/>
                    是否使用原始数据
                </label>
            </form>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=orderImport2&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="2.0导入订单(选择xlsx)">
                <label>
                    <input type=checkbox name='use_source' value='1'/>
                    是否使用原始数据
                </label>
                <a href="/data/resource/examples/order_examples_20190524.xlsx" target="_blank"><b>下载模板</b></a>
            </form>
            <p class="downlink" style="display: none;">
                <a href="" target="_blank">如果下载没有自动开始，请点我下载</a>
            </p>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=expressImport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导入物流单号(选择xlsx)">
            </form>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=superImport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导入整合包(选择xlsx)">
                <label>
                    <input type=checkbox name='use_source' value='1'/>
                    是否使用原始数据
                </label>
            </form>
        </div>
        <div>
            <form action="/shop/?sin=SinSexcel&p=orderExport&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="导出订单(选择txt,每一行一个外部订单号)">
            </form>
            <p class="downlink" style="display: none;">
                <a href="" target="_blank">如果下载没有自动开始，请点我下载</a>
            </p>
        </div>

        <div>
            <form action="/shop/?sin=SinSexcel&p=orderPay&iframecallback=impcallback" target="faker" method=post
                  enctype="multipart/form-data">
                <input type="file" name="file" value="">
                <input type="submit" value="批量支付(选择txt,每一行一个外部订单号)">
            </form>
            <p style="color:red">
                使用批量支付需配置好支付相关参数，并且只有导入的订单才可以
            </p>
        </div>

        <iframe src="" id="faker" name=faker frameborder="0" width="1000" height="500" style="display: none;"></iframe>
    </div>
    <?php
}
?>

<form method="get" action="index.php" target="_self">
    <table class="search-form">
        <input type="hidden" name="act" value="store_order"/>
        <input type="hidden" name="op" value="index"/>
        <?php if ($_GET['state_type']) { ?>
            <input type="hidden" name="state_type" value="<?php echo $_GET['state_type']; ?>"/>
        <?php } ?>

        <tr>
            <td>&nbsp;</td>
            <?php
            if ($_GET['state_type'] == 'imported_order') {
                ?>
                <td>
                    订单状态
                </td>
                <td>
                    <select name="super_order_state" id="">
                        <option value="-1">所有</option>
                        <option value="10" <?php if ($_GET['super_order_state'] == 10) echo 'selected'; ?>>未付款</option>
                        <option value="20" <?php if ($_GET['super_order_state'] == 20) echo 'selected'; ?>>已付款</option>
                        <option value="30" <?php if ($_GET['super_order_state'] == 30) echo 'selected'; ?>>已发货</option>
                        <option value="40" <?php if ($_GET['super_order_state'] == 40) echo 'selected'; ?>>已收货</option>
                    </select>
                </td>
                <?php
            }
            ?>
            <!--      --><?php //if ($_GET['state_type'] == 'store_order') { ?>
            <!--      <td><input type="checkbox" id="skip_off" value="1" -->
            <?php //echo $_GET['skip_off'] == 1 ? 'checked="checked"' : null;?><!--  name="skip_off"> <label for="skip_off">不显示已关闭的订单</label></td>-->
            <!--      --><?php //} ?>

            <th><?php echo $lang['store_order_add_time']; ?></th>
            <td class="w240"><input type="text" class="text w70" name="query_start_date" id="query_start_date"
                                    value="<?php echo $_GET['query_start_date']; ?>"/><label class="add-on"><i
                            class="icon-calendar"></i></label>&nbsp;&#8211;&nbsp;<input id="query_end_date"
                                                                                        class="text w70" type="text"
                                                                                        name="query_end_date"
                                                                                        value="<?php echo $_GET['query_end_date']; ?>"/><label
                        class="add-on"><i class="icon-calendar"></i></label></td>
            <th><?php echo $lang['store_order_buyer']; ?></th>
            <td class="w100"><input type="text" class="text w80" name="buyer_name"
                                    value="<?php echo $_GET['buyer_name']; ?>"/></td>
            <th><?php echo $lang['store_order_order_sn']; ?></th>
            <td class="w160"><input type="text" class="text w150" name="order_sn"
                                    value="<?php echo $_GET['order_sn']; ?>"/></td>
            <th>
                类型
            </th>
            <td>
                <select name="order_type" id="order_type">
                    <option value="0">全部订单</option>
                    <option value="1" <?php echo $_GET['order_type'] == "1" ? "selected" : '' ?>>内部订单</option>
                    <option value="2" <?php echo $_GET['order_type'] == '2' ? "selected" : '' ?>>外部订单</option>
                    <option value="3" <?php echo $_GET['order_type'] == '3' ? "selected" : '' ?>>汇聚推送</option>
                    <option value="4" <?php echo $_GET['order_type'] == '4' ? "selected" : '' ?>>非关闭订单</option>
                    <!--          <option value="5" --><?php //echo $_GET['order_type']=='5'?"selected":''?><!-->
                    已关闭订单</option>-->
                    <option value="6" <?php echo $_GET['order_type'] == '6' ? "selected" : '' ?>>保税订单</option>
                    <option value="7" <?php echo $_GET['order_type'] == '7' ? "selected" : '' ?>>跨境易推送</option>
                </select>
            </td>

            <td class="w70 tc"><label class="submit-border">
                    <input type="submit" class="submit" value="<?php echo $lang['store_order_search']; ?>"/>
                </label></td>
        </tr>
    </table>
</form>

<table class="search-form">
    <tr>
        <td>&nbsp;</td>
        <?php
        if ($_GET['state_type'] == 'imported_order' && ($output["store_info"]['useIETAPI'] == 1 || $_GET['bin'] == 1)) {
            ?>
            <td>
                <a class="ncsc-btn ncsc-btn-green ">
                    <input type="checkbox" class="ckall"> 全选
                </a>
            </td>
            <td>
                <a href="javascript:;" class="btn export ncsc-btn ncsc-btn-orange">
                    导出
                </a>
            </td>
            <td>
                <a href="javascript:;" class="btn pay ncsc-btn ncsc-btn-orange">
                    通联批量支付
                </a>
            </td>

        <?php if (JOINPAY_PILIANG){ ?>
            <td>
                <a href="javascript:;" class="btn joinpay ncsc-btn ncsc-btn-orange">
                    汇聚批量支付
                </a>
            </td>
        <?php } ?>

        <?php if (ZHIPAY_PILIANG){ ?>
            <td>
                <a href="javascript:;" class="btn zhipay ncsc-btn ncsc-btn-orange">
                    智付批量支付
                </a>
            </td>
        <?php } ?>

            <td style="color: red;width:500px">
                注：导出订单和批量支付只支持导入过的订单，并且导出订单只会导出已支付的。批量支付只会支付未支付的订单。
            </td>
            <script>
                $(".ckall").click(function () {
                    $('.chks').prop('checked', this.checked)
                });
                $(".btn.export").click(function () {
                    var ids = $('.chks:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    if (ids.length == 0) {
                        return layer.msg("请先选择订单");
                    }
                    $.post('/shop/?sin=SinSexcel&p=orderExportWithoutFile', {
                        arr: ids
                    }, function (msg) {
                        impcallback(msg);
                    }, 'json')
                });

                $(".btn.pay").click(function () {
                    var ids = $('.chks:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    if (ids.length == 0) {
                        return layer.msg("请先选择订单");
                    }
                    $.post('/shop/?sin=SinSexcel&p=orderPayWithoutFile', {
                        arr: ids
                    }, function (msg) {
                        impcallback(msg);
                    }, 'json')
                });

                $(".btn.zhipay").click(function () {
                    var ids = $('.chks:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    if (ids.length == 0) {
                        return layer.msg("请先选择订单");
                    }

                    $.post('/shop/?sin=SinSexcel&p=orderPayByZhipayWithoutFile', {
                        arr: ids
                    }, function (msg) {
                        if (msg.errcode == 0) {
                            var form = $(msg.errmsg.form)
                            $('body').append(form);
                            form.submit();
                        }
                    }, 'json')
                });

                $(".btn.joinpay").click(function () {
                    var ids = $('.chks:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    if (ids.length == 0) {
                        return layer.msg("请先选择订单");
                    }
                    $.post('/shop/?sin=SinSexcel&p=orderPayByJoinpayWithoutFile', {
                        arr: ids
                    }, function (msg) {
                        impcallback(msg);
                    }, 'json')
                });

            </script>
        <?php } ?>


        <?php if ($_GET["state_type"] != "imported_order") { ?>
            <td>
                <a class="ncsc-btn ncsc-btn-green ">
                    <input type="checkbox" class="checkall_s"> 全选
                </a>
            </td>

        <?php if (array_search($_GET["order_type"], ["3", "7"]) > -1){ ?>
            <td>
                <select name="wait_custom">
                    <option value="5157" <?php if ($_GET['wait_custom'] == "5157") {
                        echo 'selected';
                    } ?> >顺德陈村
                    </option>
                    <option value="1000" <?php if ($_GET['wait_custom'] == "1000") {
                        echo 'selected';
                    } ?> >海关总署
                    </option>
                </select>
            </td>
        <?php } ?>

        <?php if ($_GET["order_type"] == "3"){ ?>
            <td>
                <a href="javascript:;" class="ncsc-btn ncsc-btn-orange" id="joinpay-push-order">推送汇聚海关API</a>
            </td>
            <script>
                $("#joinpay-push-order").click(function () {
                    var ids = $('.checkitem:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    if (ids.length == 0) {
                        layer.confirm("海关代码" + $("[name='wait_custom']").val() + "！！！将推送汇聚支付最近50条订单数据！", function (index) {
                            ids = "all";
                            push_orders(ids);
                            layer.close(index);
                        });

                    } else {
                        layer.confirm("海关代码" + $("[name='wait_custom']").val() + "！！！", function (index) {
                            push_orders(ids);
                            layer.close(index);
                        });
                    }
                });

                function push_orders(ids) {
                    $.post('/shop/index.php?act=push_customs&op=orders', {
                        custom: $("[name='wait_custom']").val(),
                        orders: ids
                    }, function (msg) {
                        msg = msg.join("<br/>");
                        layer.alert(JSON.stringify(msg), {
                            area: ["500px", "auto"]
                        });
                    }, 'json')
                }
            </script>
        <?php } ?>

        <?php if ($_GET["order_type"] == "7"){ ?>
            <td>
                <a href="javascript:;" class="ncsc-btn ncsc-btn-orange" id="kjy-push-order">跨境易推送</a>
            </td>
            <script>
                $("#kjy-push-order").click(function () {
                    var ids = $('.checkitem:checked').toArray().map(function (item) {
                        return item.value;
                    });
                    layer.confirm("海关代码【" + $("[name='wait_custom']").val() + "】！将推送！", function (index) {
                        $.post('<?php echo WEB_DOMAIN;?>/kjy/AddInChinaOrder', {
                            custom: $("[name='wait_custom']").val(),
                            orders: ids
                        }, function (msg) {
                            layer.msg("已推送！请稍后查看推送结果");
                        }, 'json');

                        layer.close(index);
                    });
                });
            </script>
        <?php } ?>


            <td>
                <a href="" target="_blank"
                   style='display: none;float: right;margin-left:15px;font-weight: bold'>点我下载</a>
                <a href="javascript:;" class="ncsc-btn ncsc-btn-orange" id='_export'>导出保税订单(只会导出符合搜索条件的所有订单,如果不填写搜索条件，则导出失败，可以先点搜索以确认)</a>
                <script>
                    $('#_export').click(function () {
                        var start_time = $('#query_start_date').val();
                        var end_time = $('#query_end_date').val();
                        var buyer_name = $('[name=buyer_name]').val();
                        var order_sn = $('[name=order_sn]').val();
                        var _this = $(this);
                        layer.load();
                        $.post('/shop/?act=store_order&op=export_excel', {
                            start_time: start_time,
                            end_time: end_time,
                            buyer_name: buyer_name,
                            order_sn: order_sn
                        }, function (msg) {
                            layer.closeAll();
                            if (msg == '') {
                                layer.msg("导出失败");
                            } else {
                                _this.prev().attr('href', msg).show();
                            }
                        });
                    });
                </script>
            </td>
        <?php } ?>
    </tr>
</table>


<table class="ncsc-default-table order">
    <thead>
    <tr>
        <th class="w10"></th>
        <th colspan="2"><?php echo $lang['store_order_goods_detail']; ?></th>
        <th class="w100"><?php echo $lang['store_order_goods_single_price']; ?></th>
        <th class="w40"><?php echo $lang['store_show_order_amount']; ?></th>
        <th class="w110"><?php echo $lang['store_order_buyer']; ?></th>
        <th class="w120"><?php echo $lang['store_order_sum']; ?></th>
        <th class="w100">交易状态</th>
        <th class="w150">交易操作</th>
    </tr>
    </thead>
    <?php if (is_array($output['order_list']) and !empty($output['order_list'])) { ?>
    <?php foreach ($output['order_list'] as $order_id => $order) { ?>
    <tbody>
    <tr>
        <td colspan="20" class="sep-row"></td>
    </tr>
    <tr>
        <th colspan="20">
            <?php if ($_GET['state_type'] == 'imported_order') { ?>
                <span class="ml10">
              <input type="checkbox" class="chks" value="<?php echo $order['out_order_sn'] ?>">
          </span>
            <?php } else { ?>
                <span class="ml10">
              <input type="checkbox" class="checkitem" value="<?php echo $order['order_sn'] ?>">
          </span>
            <?php } ?>
            <span class="ml10"><?php echo $lang['store_order_order_sn'] . $lang['nc_colon']; ?><em><?php echo $order['order_sn']; ?></em>
        <?php if ($order['order_from'] == 2) { ?>
            <i class="icon-mobile-phone"></i>
        <?php } ?>
</span>
            <?php
            if ($order['is_we_groupbuy'] > 0) {
                echo '<span class="ml10" style="color:#f60">(微团订单)</span>';
            }
            ?>
            <?php
            if ($order['is_whole'] > 0) {
                echo '<span class="ml10" style="color:#f60">(批发订单)</span>';
            }
            ?>
            <span><?php echo $lang['store_order_add_time'] . $lang['nc_colon']; ?><em
                        class="goods-time"><?php echo date("Y-m-d H:i:s", $order['add_time']); ?></em></span>
            <span class="fr mr5"> <a href="index.php?act=store_order_print&order_id=<?php echo $order_id; ?>"
                                     class="ncsc-btn-mini" target="_blank" title="打印发货单"/><i class="icon-print"></i>打印发货单</a></span>
        </th>
    </tr>
    <?php $i = 0; ?>
    <?php if (!$order['goods_list'])
        $order['goods_list'] = [];
    foreach ($order['goods_list'] as $k => $goods) { ?>
        <?php $i++; ?>
        <tr>
            <td class="bdl"></td>
            <td class="w70">
                <div class="ncsc-goods-thumb"><a href="<?php echo $goods['goods_url']; ?>" target="_blank"><img
                                src="<?php echo $goods['image_60_url']; ?>"
                                onMouseOver="toolTip('<img src=<?php echo $goods['image_240_url']; ?>>')"
                                onMouseOut="toolTip()"/></a></div>
            </td>
            <td class="tl">
                <dl class="goods-name">
                    <dt><a target="_blank"
                           href="<?php echo $goods['goods_url']; ?>"><?php echo $goods['goods_name']; ?></a></dt>
                    <dd>
                        <?php if (!empty($goods['goods_type_cn'])) { ?>
                            <span class="sale-type"><?php echo $goods['goods_type_cn']; ?></span>
                        <?php } ?>
                    </dd>
                </dl>
            </td>
            <td><?php echo $goods['goods_price']; ?></td>
            <td><?php echo $goods['goods_num']; ?></td>

            <!-- S 合并TD -->
            <?php if (($order['goods_count'] > 1 && $k == 0) || ($order['goods_count']) == 1) { ?>
                <td class="bdl" rowspan="<?php echo $order['goods_count']; ?>">
                    <div class="buyer"><?php echo $order['buyer_name']; ?>
                        <p member_id="<?php echo $order['buyer_id']; ?>">
                            <?php if (!empty($order['extend_member']['member_qq'])) { ?>
                                <a target="_blank"
                                   href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $order['extend_member']['member_qq']; ?>&site=qq&menu=yes"
                                   title="QQ: <?php echo $order['extend_member']['member_qq']; ?>"><img border="0"
                                                                                                        src="http://wpa.qq.com/pa?p=2:<?php echo $order['extend_member']['member_qq']; ?>:52"
                                                                                                        style=" vertical-align: middle;"/></a>
                            <?php } ?>
                            <?php if (!empty($order['extend_member']['member_ww'])) { ?>
                                <a target="_blank"
                                   href="http://amos.im.alisoft.com/msg.aw?v=2&uid=<?php echo $order['extend_member']['member_ww']; ?>&site=cntaobao&s=2&charset=<?php echo CHARSET; ?>"><img
                                            border="0"
                                            src="http://amos.im.alisoft.com/online.aw?v=2&uid=<?php echo $order['extend_member']['member_ww']; ?>&site=cntaobao&s=2&charset=<?php echo CHARSET; ?>"
                                            alt="Wang Wang" style=" vertical-align: middle;"/></a>
                            <?php } ?>
                        </p>
                        <div class="buyer-info"><em></em>
                            <div class="con">
                                <h3><i></i><span><?php echo $lang['store_order_buyer_info']; ?></span></h3>
                                <dl>
                                    <dt><?php echo $lang['store_order_receiver'] . $lang['nc_colon']; ?></dt>
                                    <dd><?php echo $order['extend_order_common']['reciver_name']; ?></dd>
                                </dl>
                                <dl>
                                    <dt><?php echo $lang['store_order_phone'] . $lang['nc_colon']; ?></dt>
                                    <dd><?php echo $order['extend_order_common']['reciver_info']['phone']; ?></dd>
                                </dl>
                                <dl>
                                    <dt>地址<?php echo $lang['nc_colon']; ?></dt>
                                    <dd><?php echo $order['extend_order_common']['reciver_info']['address']; ?></dd>
                                </dl>
                                <dl>
                                    <dt>身份证：</dt>
                                    <dd>
                                        <?php
                                        echo $order['idcard'];
                                        ?>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </td>
                <td class="bdl" rowspan="<?php echo $order['goods_count']; ?>"><p
                            class="ncsc-order-amount"><?php echo $order['order_amount']; ?></p>
                    <p class="goods-freight">
                        <?php if ($order['shipping_fee'] > 0) { ?>
                            (<?php echo $lang['store_show_order_shipping_han'] ?>运费<?php echo $order['shipping_fee']; ?>)
                        <?php } else { ?>
                            <?php echo $lang['nc_common_shipping_free']; ?>
                        <?php } ?>
                    </p>
                    <p class="goods-pay"
                       title="<?php echo $lang['store_order_pay_method'] . $lang['nc_colon']; ?><?php echo $order['payment_name']; ?>"><?php echo $order['payment_name']; ?></p>
                </td>
                <td class="bdl bdr" rowspan="<?php echo $order['goods_count']; ?>">
                    <p><?php echo $order['state_desc']; ?>
                        <?php if ($order['evaluation_time']) { ?>
                            <br/>
                            <?php echo $lang['store_order_evaluated']; ?>
                        <?php } ?>
                    </p>

                    <!-- 订单查看 -->
                    <p><a href="index.php?act=store_order&op=show_order&order_id=<?php echo $order_id; ?>"
                          target="_blank"><?php echo $lang['store_order_view_order']; ?></a></p>

                    <!-- 物流跟踪 -->
                    <p>
                        <?php if ($order['if_deliver']) { ?>
                            <a href='index.php?act=store_deliver&op=search_deliver&order_sn=<?php echo $order['order_sn']; ?>'><?php echo $lang['store_order_show_deliver']; ?></a>
                        <?php } ?>
                    </p></td>

                <!-- 取消订单 -->
                <td class="bdl bdr" rowspan="<?php echo $order['goods_count']; ?>">

                    <?php if ($order['if_cancel']) { ?>


                        <p><a href="javascript:void(0)" class="ncsc-btn ncsc-btn-red mt5" nc_type="dialog"
                              uri="index.php?act=store_order&op=change_state&state_type=order_cancel&order_sn=<?php echo $order['order_sn']; ?>&order_id=<?php echo $order['order_id']; ?>"
                              dialog_title="<?php echo $lang['store_order_cancel_order']; ?>"
                              dialog_id="seller_order_cancel_order" dialog_width="400"
                              id="order<?php echo $order['order_id']; ?>_action_cancel"/><i
                                    class="icon-remove-circle"></i><?php echo $lang['store_order_cancel_order']; ?></a>
                        </p>
                    <?php } ?>

                    <!-- 修改价格 -->
                    <?php if ($order['if_modify_price']) { ?>
                        <p><a href="javascript:void(0)" class="ncsc-btn-mini ncsc-btn-orange mt10"
                              uri="index.php?act=store_order&op=change_state&state_type=modify_price&order_sn=<?php echo $order['order_sn']; ?>&order_id=<?php echo $order['order_id']; ?>"
                              dialog_width="480" dialog_title="<?php echo $lang['store_order_modify_price']; ?>"
                              nc_type="dialog" dialog_id="seller_order_adjust_fee"
                              id="order<?php echo $order['order_id']; ?>_action_adjust_fee"/><i class="icon-pencil"></i>修改运费</a>
                        </p>
                    <?php } ?>

                    <!-- 发货 -->
                    <?php if ($order['if_send']) { ?>

                        <?php if ($order["qk_order"] == 1 ) { ?>
                            <p>
                                <?php if ($order['qk_buyer_confirm'] == 1) echo "<font style='color:indianred'>买家已确认付款</font>" ?>
                                <?php if ($order['qk_buyer_confirm'] != 1) echo "买家未确认付款" ?>
                            </p>
                            <?php
                                if($order["qk_seller_confirm"] != 1){
                                    ?>
                                    <p><a href="javascript:void(0)" class="ncsc-btn ncsc-btn-blue mt5 seller-confirm" data-id="<?php echo $order['order_id']?>">确认已付款</a></p>
                                    <?php
                                } else {
                            ?>
                                  <font style='color:indianred'>卖家已确认收款</font>
                            <?php
                                }
                            ?>
                        <?php } ?>

                        <p><a class="ncsc-btn ncsc-btn-green mt10"
                              href="index.php?act=store_deliver&op=send&order_id=<?php echo $order['order_id']; ?>"/><i
                                    class="icon-truck"></i><?php echo $lang['store_order_send']; ?></a></p>
                    <?php } ?>

                    <!-- 锁定 -->
                    <?php if ($order['if_lock']) { ?>
                        <p><?php echo '退款退货中'; ?></p>
                    <?php } ?></td>

            <?php } ?>
            <!-- E 合并TD -->
        </tr>

        <!-- S 赠品列表 -->
        <?php if (!empty($order['zengpin_list']) && $i == count($order['goods_list'])) { ?>
            <tr>
                <td class="bdl"></td>
                <td colspan="4" class="tl">
                    <div class="ncsc-goods-gift">赠品：
                        <ul><?php foreach ($order['zengpin_list'] as $zengpin_info) { ?>
                            <li>
                                <a title="赠品：<?php echo $zengpin_info['goods_name']; ?> * <?php echo $zengpin_info['goods_num']; ?>"
                                   href="<?php echo $zengpin_info['goods_url']; ?>" target="_blank"><img
                                            src="<?php echo $zengpin_info['image_60_url']; ?>"
                                            onMouseOver="toolTip('<img src=<?php echo $zengpin_info['image_240_url']; ?>>')"
                                            onMouseOut="toolTip()"/></a></li>
                        </ul>
                        <?php } ?>
                    </div>
                </td>
            </tr>
        <?php } ?>
        <!-- E 赠品列表 -->

    <?php } ?>
    <?php }
    } else { ?>
        <tr>
            <td colspan="20" class="norecord">
                <div class="warning-option"><i
                            class="icon-warning-sign"></i><span><?php echo $lang['no_record']; ?></span></div>
            </td>
        </tr>
    <?php } ?>
    </tbody>
    <tfoot>
    <?php if (is_array($output['order_list']) and !empty($output['order_list'])) { ?>
        <tr>
            <td colspan="20">
                <div class="pagination"><?php echo $output['show_page']; ?></div>
            </td>
        </tr>
    <?php } ?>
    </tfoot>
</table>
<script charset="utf-8" type="text/javascript"
        src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/i18n/zh-CN.js"></script>
<link rel="stylesheet" type="text/css"
      href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"/>
<script type="text/javascript">
    $(function () {
        $('#query_start_date').datepicker({dateFormat: 'yy-mm-dd'});
        $('#query_end_date').datepicker({dateFormat: 'yy-mm-dd'});
        $(".checkall_s").click(function () {
            $('.checkitem').prop('checked', this.checked)
        });
        $('#skip_off').click(function () {
            url = location.href.replace(/&skip_off=\d*/g, '');
            window.location.href = url + '&skip_off=' + ($('#skip_off').attr('checked') ? '1' : '0');
        });
    });

    $(".seller-confirm").click(function () {
        var t = $(this);
        layer.confirm("此操作不可逆，请确认已经收到款项", function (index) {
            layer.close(index);
            layer.load();

            var id = t.data("id");
            $.get("?act=store_order&op=sellerConfirm", {id:id}, function (msg) {
                if(msg == 'ok'){
                    layer.msg("操作成功", {time: 1000}, function () {
                        location.reload()
                    });
                } else{
                    layer.msg(msg);
                }
            });
        })

    });
</script>
